/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cashmate.struts;

import com.cashmate.hibernate.pojo.Employees;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;

/**
 *
 * @author clione
 */
public class CancelIncentive extends ActionSupport {

    private Logger logger = Logger.getLogger(CancelIncentive.class);
    private final Employees emps = (Employees) ServletActionContext.getRequest().getSession().getAttribute("employee");

    @Action(value = "/cancel-incentive")
    @Override
    public String execute() throws Exception {
        try {
            ServletActionContext.getRequest().getSession().removeAttribute("incentiveList");
        } catch (Exception ex) {
            if (emps != null) {
                logger.fatal("(" + emps.getIdnumber() + "):" + ex.getLocalizedMessage(), ex);
            } else {
                logger.fatal(ex.getLocalizedMessage(), ex);
            }
            ex.printStackTrace();
            //add action errors this will correspond to <s:actionerror/> in a struts-enabled jsp page.
            addActionError(ex.getLocalizedMessage());

            //if error then chain result to messages.jsp, which will display errors/messages.
            return ERROR;
        }
        return NONE;
    }
}
